t=int(input())
while t!=0:
x,y=map(int,input().split())
a,b=map(int,input().split())
diff=x-y
if diff<0:
diff=-(diff)
p=min(x,y)
fin=(diff*a)+(p*b)
fin1=(x*a+y*a)
print(min(fin,fin1))
t=t-1
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod = 1e9+7;
// sieve of earonsthes
// const int N = 1e8;
// bool prime[N+1];
// void sieve()
// {
// memset(prime, true, sizeof(prime));
// prime[0] = false;
// prime[1] = false;
// for(ll i = 2; i*i <= N; i++)
// {
// if(prime[i] == true)
// {
// for(ll j = i*i; j <= N; j += i)
// {
// prime[j] = false;
// }
// }
// }
// }
// binary exponention
// ll solve(ll a, ll b)
// {
// if(b == 0) return 1;
// ll temp = solve(a, b/2);
// if(b % 2 == 0) return (temp % mod * temp % mod) % mod;
// else return (((temp*temp) % mod)*a % mod) % mod;
// }
// sum of digits
// int sum(int n)
// {
// int s = 0;
// while(n)
// {
// s += (n % 10);
// n /= 10;
// }
// return s;
// }
// next prime number
// ll next_prime(ll N)
// {
// if (N <= 1)
// return 2;
// ll p = N;
// bool found = false;
// while (!found) {
// p++;
// if(prime[p] == true)
// found = true;
// }
// return p;
// }
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t;
cin >> t;
//sieve();
while(t--)
{
ll x, y, a, b;
cin >> x >> y >> a >> b;
ll diff = abs(x-y);
ll n = min(x, y);
ll sum = 0;
sum += (diff*a);
ll a_cost = 2LL*n*a;
ll b_cost = 1LL*n*b;
sum += min(a_cost, b_cost);
cout<<sum<<endl;
}
}
1038A - Equality | 1061A - Coins |
1676E - Eating Queries | 1447A - Add Candies |
1721D - Maximum AND | 363C - Fixing Typos |
1401A - Distance and Axis | 658A - Bear and Reverse Radewoosh |
1721E - Prefix Function Queries | 977E - Cyclic Components |
1140D - Minimum Triangulation | 75C - Modified GCD |
1722A - Spell Check | 1722B - Colourblindness |
1722D - Line | 1722C - Word Game |
1722G - Even-Odd XOR | 552E - Vanya and Brackets |
933A - A Twisty Movement | 1722F - L-shapes |
1196B - Odd Sum Segments | 1325D - Ehab the Xorcist |
552B - Vanya and Books | 1722E - Counting Rectangles |
168A - Wizards and Demonstration | 168B - Wizards and Minimal Spell |
7A - Kalevitch and Chess | 912B - New Year's Eve |
1537C - Challenging Cliffs | 879B - Table Tennis |